﻿// <copyright file="RouteConfig.cs" company="Clever Software">
// Copyright (c) 2013, 2014 All Right Reserved, http://www.cleversoftware.by
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Clever Software</author>
// <email>info@cleversoftware.by</email>
// <date>2014-02-04</date> 
// <summary>CleverCMS source code</summary>

namespace CleverCMS.Web.App_Start
{
    using System.Web.Mvc;
    using System.Web.Routing;
    using LowercaseRoutesMVC;

    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            #region Blog

            routes.MapRouteLowercase(name: "blog_category",
                            url: "blog/categories/{category}/{page}",
                            defaults: new { controller = "blog", action = "index", category = UrlParameter.Optional, page = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRouteLowercase(name: "blog_tags",
                            url: "blog/tags/{tag}/{page}",
                            defaults: new { controller = "blog", action = "index", tag = UrlParameter.Optional, page = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRouteLowercase(name: "blog_archive",
                            url: "blog/archive/{month}/{year}/{page}",
                            defaults: new { controller = "blog", action = "archive", month = UrlParameter.Optional, year = UrlParameter.Optional, page = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRouteLowercase(name: "blog_entry",
                            url: "blog/{category}/entry/{id}",
                            defaults: new { controller = "blog", action = "Entry", category = UrlParameter.Optional, id = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRouteLowercase(name: "blog_list",
                            url: "blog/page/{page}",
                            defaults: new { controller = "blog", action = "index", page = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRoute(name: "blog_comment",
                            url: "blog/addcomment/",
                            defaults: new { controller = "blog", action = "AddComment" },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            routes.MapRouteLowercase(name: "blog",
                            url: "blog/{page}",
                            defaults: new { controller = "blog", action = "index", page = UrlParameter.Optional },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            #endregion

            #region Cms

            routes.MapRouteLowercase(name: "pages",
                            url: "pages/{name}",
                            defaults: new { controller = "home", action = "content", id = 0, name = string.Empty },
                            namespaces: new string[] { "CleverCMS.Web.Controllers" });

            
            routes.MapRouteLowercase("general", "{controller}/{action}/{id}", new { controller = "home", action = "default", id = UrlParameter.Optional }, new[] { "CleverCMS.Web.Controllers" });

            #endregion

        }
    }
}